//
//  YLPresentationController.swift
//  sina_yl
//
//  Created by 袁量 on 2017/5/21.
//  Copyright © 2017年 袁量. All rights reserved.
//

import UIKit

class YLPresentationController: UIPresentationController {
    lazy var presentViewFrame : CGRect = CGRect.zero
    lazy var coverView : UIView = UIView()
    override func containerViewWillLayoutSubviews() {
        super.containerViewWillLayoutSubviews()
        presentedView?.frame = presentViewFrame
        setUpCoverView()
    }
}
extension YLPresentationController {
    func setUpCoverView() {
        containerView?.insertSubview(coverView, at: 0)
        coverView.backgroundColor = UIColor(white: 0.8, alpha: 0.2)
        coverView.frame = containerView!.bounds
        let tapGes = UITapGestureRecognizer(target: self, action: #selector(YLPresentationController.coverViewClick))
        coverView.addGestureRecognizer(tapGes)
    }
}
extension YLPresentationController {
    func coverViewClick() {
//        let homeVC = HomeViewController()
//        WWLog(mesage: "点击了蒙版")
//        homeVC.titleBtn.isSelected = !homeVC.titleBtn.isSelected
        presentedViewController.dismiss(animated: true, completion: nil)
    }
}
